package com.shawn.model.vo;

import com.shawn.model.entity.UserInfo;
import com.shawn.model.mongo.FocusUser;
import com.shawn.model.mongo.Video;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class VideoVo implements Serializable {
    private String id;//id
    private Integer userId;//作者id
    private String avatar;//头像 2
    private String nickname;//昵称 2

    private String cover;//封面
    private String videoUrl;//视频地址 1
    private String signature;//视频文案

    private Integer likeCount;//点赞数量 1
    private Integer commentCount;//评论数量 1

    private Integer hasFocus=0;//是否关注
    private Integer hasLiked =0;//是否已赞

    public static VideoVo init(Video vi, UserInfo ui){
        VideoVo vo = new VideoVo();
        BeanUtils.copyProperties(vi,vo);
        BeanUtils.copyProperties(ui,vo);
        vo.setId(vi.getId().toHexString());
        vo.setUserId(vi.getUserId().intValue());
        vo.setCover(vi.getPicUrl());
        vo.setSignature(vi.getText());
        return vo;
    }
}